package com.vitalfit.strategy.factory;

import com.vitalfit.strategy.UserStrategy;
import com.vitalfit.strategy.strategyImpl.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Component
public class UserStrategyFactory {
    private final Map<String, UserStrategy> strategies;

    @Autowired
    public UserStrategyFactory(CreateTrainerStrategy createTrainerStrategy, QueryTrainerStrategy queryTrainerStrategy,
                               EditTrainerStrategy editTrainerStrategy, QueryCustomerStrategy queryCustomerStrategy,
                               EditCustomerStrategy editCustomerStrategy) {
        strategies = new ConcurrentHashMap<>();
        strategies.put("Trainer:create", createTrainerStrategy);
        strategies.put("Trainer:query",queryTrainerStrategy);
        strategies.put("Trainer:edit",editTrainerStrategy);
        strategies.put("Customer:query",queryCustomerStrategy);
        strategies.put("Customer:edit",editCustomerStrategy);

    }

    public UserStrategy getStrategy(String userType, String action) {
        return strategies.get(userType + ":" + action);
    }
}
